/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package onpu_dms_xls.exceptions;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 *
 * @author snbm
 */
public class MyException extends Exception {

    protected String className;
    protected String methodName;
    protected String errorMessage;

    public MyException(String className, String methodName, String errMess) {
        this.className = className;
        this.methodName = methodName;
        this.errorMessage = errMess;
    }

    public MyException(String message, Throwable cause) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        cause.printStackTrace(pw);
        this.errorMessage = message + sw.toString();
    }

    @Override
    public String toString() {
        return "--- Exception:"
                + "\n--in class: " + className
                + "\n--in method/section: " + methodName
                + "\n--with message: " + errorMessage;
    }

    @Override
    public String getMessage() {
        return "class:" + className + "\tmethod:" + methodName + "\terrMess:" + errorMessage;
    }
}
